import Vue from 'vue';
import VueI18n from 'vue-i18n'
import Locales from './locale';
import zhLocale from '_c/iview/locale/lang/zh-CN';
import enLocale from '_c/iview/locale/lang/en-US';

// 自动设置语言
const navLang = navigator.language;
const localLang = (navLang === 'zh-CN' || navLang === 'en-US') ? navLang : false;
const lang = window.localStorage.lang || localLang || 'zh-CN';

Vue.config.lang = lang;

Vue.use(VueI18n)
Vue.locale = () => {}
// 多语言配置
const locales = Locales;
const messages = {
    'zh-CN':Object.assign(zhLocale, locales['zh-CN']),
    'en-US': Object.assign(enLocale, locales['en-US'])
}
const i18n = new VueI18n({
    locale: lang,
    messages
})

export default i18n
